package com.day16.ex09;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class PokerDemoStronger {
    public static void main(String[] args) {
        HashMap<Integer,String> hm=new HashMap<Integer,String>();
        ArrayList<Integer>array=new ArrayList<Integer>();
        String[] colors={"红桃","方片","梅花","黑桃"};
        String[] numbers={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        int index=0;
        for(String number:numbers){
            for(String color:colors){
                hm.put(index,color+number);
                    array.add(index);
                    index++;
                }
            }
            hm.put(index,"小王");
            array.add(index);
            index++;
            hm.put(index,"大王");
            array.add(index);
            Collections.shuffle(array);
            TreeSet<Integer> lqxSet=new TreeSet<Integer>();
            TreeSet<Integer> lySet=new TreeSet<Integer>();
            TreeSet<Integer> fqySet=new TreeSet<Integer>();
            TreeSet<Integer> dqSet=new TreeSet<Integer>();
            for (int i = 0; i < array.size(); i++) {
                int x=array.get(i);
                if (i>array.size()-3){
                    dqSet.add(x);
                } else if (i%3==0) {
                    lqxSet.add(x);
                } else if (i%3==1) {
                    lySet.add(x);
                } else if (i%3==2) {
                    fqySet.add(x);
                }
            }
            lookPoker("刘强东",lqxSet,hm);
            lookPoker("李彦宏",lySet,hm);
            lookPoker("方enze",fqySet,hm);
            lookPoker("底牌",dqSet,hm);
    }
        public static void lookPoker(String name,TreeSet<Integer>array,HashMap<Integer,String>hm){
            System.out.print(name+"的牌是：");
            for (Integer x:array) {
                String lookPoker=hm.get(x);
                System.out.print(lookPoker+"");
            }
            System.out.println();

    }
}
